/**
 * 将cookie字符串转换为数组
 * @param cookieString
 * @returns {*[]}
 */
const cookieStringToArray = (cookieString) => {
    // 将 cookie 字符串按分号和空格分割
    const cookieArray = cookieString.split('; ');
    const cookies = [];

    // 遍历分割后的数组，将每个条目拆分为 name 和 value 并添加到 cookies 数组中
    for (const cookie of cookieArray) {
        const parts = cookie.split('=');
        if (parts.length === 2) {
            cookies.push({ name: parts[0], value: parts[1] });
        }
    }
    return cookies;
}

module.exports = {
    cookieStringToArray
}